/**
 * 
 */
package idv.takeshi.software.productline.bookstore.domain.model.category;

import idv.takeshi.software.productline.bookstore.domain.model.valueobject.InternationalText;

import org.apache.commons.lang.Validate;

/**
 * A Factory for instantiate category instance.
 * @author takeshi
 *
 */
public class CategoryFactory {
	
	public Category newInstance(InternationalText name) throws CategoryNameNotSetException{
		Validate.notNull(name, "name shall always not be null");
		
		Category category = new Category();
		if(!name.isAllNeededLocalesTextFilled())
			throw new CategoryNameNotSetException("All needed name locale's not set");
		category.setName(name);
		
		return category;
	}

}
